/********************************************************************
	TABAL ENGINE - 2012/11/04
	author:		Marc Cuscullola
	
	purpose:	Defines an effect from a shader file
*********************************************************************/
#pragma once

#ifndef __GRAPHICS__EFFECT__INCLUDED_H__
#define __GRAPHICS__EFFECT__INCLUDED_H__

#pragma warning (disable:4005)

#include "MathTypes.h"
#include "d3dx11effect.h"
#include <string>
#include <d3dx11.h>
#include <D3Dcompiler.h>
#include <vector>

class CXMLTreeNode;

class CEffect
{
public:
	CEffect(CXMLTreeNode& _node);
	~CEffect();

	bool	Load	();
	bool	Reload	();

	ID3DX11EffectTechnique*	GetTechniqueByName(const std::string& _sName);
	const std::string&		GetEffectName	() const;
	ID3DX11Effect*			GetEffect		()	const { return m_pEffect; }
	ID3DX11EffectVariable*	GetParameterBySemantic(const std::string& _sSemantic, bool _bWarning = true);
	
	inline ID3DX11EffectVariable*	GetWorldMatrixParameter() const;
	inline ID3DX11EffectVariable*	GetViewMatrixParameter() const;
	inline ID3DX11EffectVariable*	Get2DViewMatrixParameter() const;
	inline ID3DX11EffectVariable*	GetProjectionMatrixParameter() const;
	inline ID3DX11EffectVariable*	GetOrthographicMatrixParameter() const;
	inline ID3DX11EffectVariable*	GetViewProjectionMatrixParameter() const;
	inline ID3DX11EffectVariable*	GetTextureParameter(uint8 _index) const;
private:
	bool	LoadEffect();
	void	SetNullParameters();

private:
	ID3DX11Effect*		m_pEffect;

	std::string			m_sEffectName;
	std::string			m_sFileName;

	ID3DX11EffectVariable*	m_pWorldMatrixParameter;
	ID3DX11EffectVariable*	m_pViewMatrixParameter;
	ID3DX11EffectVariable*	m_p2DViewMatrixParameter;
	ID3DX11EffectVariable*	m_pProjectionMatrixParameter;
	ID3DX11EffectVariable*	m_pOrthographicMatrixParameter;
	ID3DX11EffectVariable*	m_pViewProjectionMatrixParameter;
	std::vector<ID3DX11EffectVariable*> m_TextureParameterVector;
};

#include "Effect.inl"

#endif //__GRAPHICS__EFFECT__INCLUDED_H__